<?php
	if (!class_exists('Factories')) {
		function __autoload($class_name){
			$dirs = array(
				'../Factories/',
				'../cntrlr/',
				'../mdl/',
				'../mdl/Delete/',
				'../mdl/Select/',
				'../mdl/Update/',
				'../mdl/Insert/',
				'../'
			);
			foreach($dirs as $dir){
				if(file_exists($dir.$class_name . '.php')){
					require_once($dir.$class_name . '.php');
					return;
				}
			}
			throw new BadFunctionCallException("No such Object file");
		}
	}
	$factory = Factories::Init();
	$db      = $factory->databaseObject("select", "orders");
	if (isset($_GET["id"])) {
		$update      = $factory->databaseObject("update", "orderstatus");
		if (strcmp($_GET["value"]," Приета ")==0){

			$update->changeStatus(true ,$_GET["id"]);
		} else {
			$update->changeStatus(false,$_GET["id"]);
		}
	}

	$orders = $db->extractNotApprovedOrders();
	require_once"../vw/adminside/NewOrdersView.php";


?>
